***********************************************************************************
********"Macroprudential Regulation, Quantitative Easing, and Bank Lending"********
***********************************************************************************
* This file sets up all the dataset needed to perform the placebo test discussed 
* in Appendix II
***********************************************************************************
***********************************************************************************


*==================================================================================
**# Bookmark (input)
clear *
import sas using $inputdirectory/typeplacebo, case(lower)

rename abi bankid
sort bankid
labmask type, values(description)
drop description

**# Bookmark (saving dataset - bank type - e.g. joint stock company, mutual bank)
compress
save $inputdirectory/INB_typePLACEBO, replace


*==================================================================================
**# Bookmark (input)
clear *
import sas using $inputdirectory/gruplacebo, case(lower)

rename ente_segn bankid
duplicates drop gru bankid, force

* Changes suggested by the supervisory department
* LINES NOT SHOWN

**# Bookmark (saving dataset - map of the groups)
compress
save $inputdirectory/INB_gruPLACEBO, replace


*==================================================================================
**# Boomark (input)
clear *
import sas using $inputdirectory/fsplacebo

rename ABI bankid
rename VOCE voce
rename IMPORTO importo
keep if DATA==20131231
drop DATA
keep if inlist(voce, 52000600)

format importo %20.0g
* LINE NOT SHOWN (NAMES OF BANKS/BALANCE-SHEET ITEMS ALREADY DROPPED IN THE PSEUDO DATASET)
reshape wide importo, i(bankid) j(voce)
rename importo52000600 cash
recode * (.=0)

**# Bookmark (saving dataset - cash from the financial statement)
compress
save $inputdirectory/INB_fsPLACEBO, replace


*==================================================================================
**# Bookmark (input)
clear *
import sas using $inputdirectory/ecbdepo, case(lower)

rename dat date
tostring(date), replace
gen xxx=date(date, "YMD")
drop date
gen time=mofd(xxx)
drop xxx
format time %tm
rename ente_segn bankid
drop abi

merge m:1 bankid using $inputdirectory/INB_gruPLACEBO, keepus(gru)
keep if _merge!=2
drop _merge
replace gru=bankid if gru==.
drop bankid
collapse (sum) ecbdepo, by(gru time)

**# Bookmark (saving dataset - deposits at the ECB)
compress
save $inputdirectory/INB_ecbdepoPLACEBO, replace

